home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Scripts / ThinkC.vu < prev    next >
Encoding:
Text File  |  1993-12-17  |  6.5 KB  |  181 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        ThinkC.vu
  5. #
  6. #    Contains:    Quick look test script for Think C version 5.0.4
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #     <1.0.5>     9/30/93    KTA        Initialize gFileName prior to gApptitle being updated by
  19. #                                    launchTwitch().
  20. #     <1.0.2>     6/16/93    NAGA        Renaming InitGlobals(ScriptLevel)to InitGlobals(ScriptLevel)
  21. #        <1+>     5/25/93    NAGA        Adding header and porting old files to follow new standards
  22. #
  23. # ****************************************************************************
  24. #
  25.  
  26.  
  27.  
  28. ########################################################################
  29. #                            External libraries 
  30. #=======================================================================
  31. Libraries "Output.Lib", "DoTasks.Lib","Draw.Lib","StandardFile.Lib","UserInterface.Lib","DA.Lib", "Font.Lib", "Globals.Lib", "LaunchQuit.Lib", "TCS.Lib";
  32.  
  33.  
  34. #########################################################################
  35. ########               Application Specific Tasks
  36. #########################################################################
  37.  
  38. #########################################################################
  39. #                        InitAppGlobals()
  40. #========================================================================
  41. # Author:        KA
  42. # Description:    Sets up tools and fonts for Think C.  This task
  43. #                must be called first.
  44. # Parameters:    None
  45. # Returns:        Nothing
  46. # Examples:        InitAppGlobals()
  47. #========================================================================
  48. # History:
  49. #
  50. ########################################################################
  51. task InitAppGlobals()
  52. begin
  53.     
  54.     logstr("setting up {global gApptitle}'s globals");            
  55.     global gScreenInset := {0,20,0,0};        # Screen inset
  56.     global gPaletteList :=    {};
  57.     global gToolList := {};
  58. end; # InitAppGlobals
  59.  
  60. #########################################################################
  61. #                            ThinkCScrapText()
  62. #========================================================================
  63. # Author:        ML
  64. # Description:    Paste text into Think C Document
  65. # Parameters:    None
  66. # Returns:        Nothing
  67. # Examples:        ThinkCScrapText();
  68. # Assumptions:    None 
  69. # Applications:    Think C
  70. #========================================================================
  71. # History:
  72. #
  73. #########################################################################
  74. task ThinkCScrapText()
  75. begin
  76.     logstr("Setting up for ScrapText");
  77.     TypeStr("/*");            # Commment out Scrapbook paste
  78.     Scrapbook(global kScrapTEXT);
  79.     TypeStr("*/");            # Commment out Scrapbook paste
  80. end;
  81.  
  82. #########################################################################
  83. #                            SimpleProgram()
  84. #========================================================================
  85. # Author:        AM
  86. # Description:    Create and run a simple program
  87. # Parameters:    None
  88. # Returns:        Nothing
  89. # Examples:        Views();
  90. # Assumptions:    None 
  91. # Applications:    THINK C        
  92. #========================================================================
  93. # History:  Adapted from Think Pascal Program 1/22/92 AEM
  94. #     KTA        12/08/92    Added Ansi library and running Hasta
  95. #########################################################################
  96. task SimpleProgram() 
  97. begin
  98.     Temp := Global gAppVerify;        # Disable Appverify because running will cause an application switch
  99.     gAppVerify := 0;
  100.  
  101.     LogStr('Creating and Compiling a Simple Program',3);
  102.     SelectMenuItem("Add", "Source");        # add doc to the project
  103.     # add ANSI to the project
  104.     SelectMenuItem("Add…", "Source");        
  105.     TypeStr('C Lib');
  106.     SpecialKey(Returnkey,"Return Key");
  107.     TypeStr('ANSI');
  108.     SpecialKey(Returnkey,"Return Key");
  109.     SelectButton("Done");
  110.  
  111.     TypeList({    '/*',
  112.                 ' * Hasta.c',
  113.                 '* A simple program in C',
  114.                 '*/',
  115.                 '',
  116.                 '#include <stdio.h>',
  117.                 'void main() {',
  118.                 'printf("Hasta La Vista, Baby!!!");',
  119.                 '}'    }, 1, 1);
  120.                 
  121.     SelectMenuItem("Compile","Source");
  122.     SelectMenuItem("Save","File");
  123.     SelectMenuItem("Run", "Project");        # Loading and compiling libraries is
  124.                                             # too complex a process for a quick look.
  125.                                             
  126.     ## Various dialog dismissal
  127.     SpecialKey(returnKey,"Return Key");        # return after project runs
  128.     SpecialKey(returnKey,"Return Key");        # return after project runs
  129.     gAppVerify := Temp;
  130. end;
  131.  
  132. ################################################################################
  133. ####################             Main script                    ####################
  134. ################################################################################
  135. script ThinkC (ScriptLevel:= -1)
  136. begin
  137.     InitGlobals(ScriptLevel);            # initialize your general globals
  138.     InitDraw();
  139.     InitFonts();
  140.     global gApptitle := "Think C";
  141.     global gAppVersion := '5';        # version of app you will be running
  142.     global gFileName := "@!@-{gBuildVers}-{gAppTitle}.c";# This is used in SaveAs when saving files
  143.     SuiteStart('ThinkC.vu');                    # begin a new test suite
  144.     if LaunchTwitch("{gAppTitle}",gAliasDirectory) # launch or twitch to your app
  145.     begin
  146.         global gProjectName := "@!@-{gBuildVers}-{gAppTitle}.proj";
  147.         global gCustomScrapText:= task ThinkCScrapText;     # define app specific task    
  148.         InitAppGlobals();                                    # init app specific globals
  149.         (*
  150.         *)
  151.  
  152.         ## Begin with StandardFile
  153. #            if(match[button t:'New'])
  154. #            begin
  155. #                SelectButton('New');
  156. #                SaveAs(global gProjectName);
  157. #            end;
  158.         
  159.         DoSetUpApp("Cancel",-1,{'New Project…','Project'},,,,0); # first set up project
  160.         SaveAs(global gProjectName);                        # save the project
  161.         
  162.         DoSetUpApp(,-1,,0,1);                                # then set up the file
  163.         
  164.         SimpleProgram();
  165.             ##DoText(0);            # No Font menus in Think C
  166.         DoWindow();                    # Vertical scroll could fail if nothing in document
  167.             ##DoDraw(0);            # No Draw Tools in Think C
  168.         
  169.         DoCloseApp(1,-1);             # The About Box disables VU
  170.         LogStr("############################# LIMITATIONS: ############################");
  171.         LogStr("No Draw Tools or Font menus in Think C, so DoText and DoDraw not done.");
  172.         LogStr("Vertical scroll will fail because doc isn't long enough");
  173.         LogStr("Final save will fail because we've already saved before executing program");
  174.     end; # if LaunchTwitch("{gAppTitle}",gAliasDirectory)
  175.     SuiteEnd();
  176. end; # script ThinkC
  177.  
  178. ## Still needed
  179. # 1) Vertical scroll could fail if nothing in document
  180. # 4) The revert save does not work because the document is already saved
  181.